package enumAndAnnotation;

/**
 * 枚举练习
 */
public class EnumExercise09 {

    public static void main(String[] args) {
        /*
            1)创建一个Color枚举类
            2)有RED BLUE BLACK YELLOW GREEN 五个枚举值/对象
            3)Color 有三个属性 redValue greenValue blueValue
            4)创建构造方法 参数包含这三个属性
            5)每个枚举值都要给这三个属性赋值，三个属性对应值分别是
              red:255,0,0 blue:0,0,255 yellow:255,255,0 green:0,255,0 black:0,0,0
            6)定义接口，里有方法show()，要求Color实现该接口
            7)show方法显示三属性的值
            8)将枚举对象在switch中匹配使用
         */
        Color color = Color.RED;
        color.show();

        switch (color) {
            case RED:
                System.out.println("匹配到红色");
                break;
            case BLUE:
                System.out.println("匹配到蓝色");
                break;
            case BLACK:
                System.out.println("匹配到黑色");
                break;
            case GREEN:
                System.out.println("匹配到绿色");
                break;
            case YELLOW:
                System.out.println("匹配到黄色");
                break;
            default:
                System.out.println("未匹配到颜色");
        }
    }
}

interface test {

    public void show();
}

enum Color implements test {

    RED(255,0,0),BLUE(0,0,255),YELLOW(255,255,0),GREEN(0,255,0),BLACK(0,0,0);

    private int redValue;

    private int greenValue;

    private int blueValue;

    private Color (int redValue, int greenValue, int blueValue) {
        this.redValue = redValue;
        this.greenValue = greenValue;
        this.blueValue = blueValue;
    }

    @Override
    public void show() {
        System.out.println("属性值为：" + redValue + "," + greenValue + "," + blueValue);
    }


}